﻿using _1_Interfaces.Interfaces.Cjw;
using _1_Interfaces.Models.Dtos.Cjw;
using _1_Interfaces.Models.Tables.Cjw;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace _3_Controllers.Controllers.Cjw
{
    /// <summary>
    /// 管理员管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CjwAdminController : ControllerBase
    {
        private IAdminService _adminService;
        public CjwAdminController(IAdminService adminService)
        {
            _adminService = adminService;
        }

        /// <summary>
        /// 管理员注册
        /// </summary>
        /// <param name="adminRegisterDto"></param>
        /// <returns></returns>
        [HttpPost]
        public bool AdminRegister(AdminRegisterDto adminRegisterDto)
        {
            return _adminService.AdminRegister(adminRegisterDto);
        }

        /// <summary>
        /// 管理员登陆
        /// </summary>
        /// <param name="adminName">用户名</param>
        /// <param name="adminPassword">密码</param>
        /// <returns></returns>
        [HttpGet]
        public AdminListDto AdminLogin(string adminName, string adminPassword)
        {
            return _adminService.AdminLogin(adminName, adminPassword);
        }

        /// <summary>
        /// 上传图片,通过Form表单提交
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        [HttpPost]
        public string UploadPictures(IFormFile file)
        {
            return _adminService.UploadPictures(file);
        }

        /// <summary>
        /// 获取员工信息列表
        /// </summary>
        /// <param name="adminName">员工姓名</param>
        /// <param name="sex">1、0</param>
        /// <param name="position">、前台管理、护士、医生</param>
        /// <param name="pageIndex">第几页</param>
        /// <param name="pageSize">一页几条</param>
        /// <returns></returns>
        [HttpGet]
        public GetAdminListDto GetAdminList(string adminName, string sex, string position, int pageIndex, int pageSize)
        {
            return _adminService.GetAdminList(adminName, sex, position, pageIndex, pageSize);
        }

        /// <summary>
        /// 修改员工个人信息
        /// </summary>
        /// <param name="adminList"></param>
        /// <returns></returns>
        [HttpPost]
        public bool UpdateAdmin(AdminList adminList)
        {
            return _adminService.UpdateAdmin(adminList);
        }

        /// <summary>
        /// 获取员工列表
        /// </summary>
        /// <param name="position"></param>
        /// <returns></returns>
        [HttpPost]
        public List<AdminList> GetAdminListByPosition(string position)
        {
            return _adminService.GetAdminListByPosition(position);
        }

        /// <summary>
        /// 获取个人信息
        /// </summary>
        /// <param name="adminName">用户名</param>
        /// <returns></returns>
        [HttpGet]
        public AdminList GetMyInformationByAdminName(string adminName)
        {
            return _adminService.GetMyInformationByAdminName(adminName);
        }
    }
}
